package com.cms.service.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cms.domain.Item;
import com.cms.mapper.ItemDao;
import com.cms.service.ItemService;


@Service
public class ItemServiceImpl implements ItemService{

	@Autowired
	private ItemDao entityDao;
	
	public Item getById(Long id){
		return entityDao.getById(id);
	}

	public List<Item> getByName(Long id_sbj,String name){
		return entityDao.getByName(id_sbj, name);
	}
	
	public List<Item> getList(Long id_sbj){
		return entityDao.getList(id_sbj);
	}

	public List<Item> getList(Long id_sbj, int pageNum, int pageSize){
		int startIndex = 0;
		if(pageNum>1){
			startIndex = (pageNum-1)*pageSize;
		}
		return entityDao.getListForPage(id_sbj, startIndex, pageSize);
	}
	
	public void add(Item entity){
		entity.setCreatetime(new Date());
		entityDao.add(entity);
	}

	public void update(Item entity){
		entityDao.update(entity);
	}

	public void delete(Item entity){
		entityDao.delete(entity);
	}

	public Integer getRowCount(Long id_sbj){
		return entityDao.getRowCount(id_sbj);
	}
}

